import { useEffect, useState } from 'react'
import { getChannelAPI } from '@/apis/article'
function useChannel() {
  // 获取频道列表
  const [channelList, setChannelList] = useState([])
  useEffect(() => {
    const getChannelList = async () => {
      const res = await getChannelAPI()
      setChannelList(res.data.channels)
    }
    getChannelList()
  }, [])
  // 把组件中需要的数据return出去 使用对象的原因是好解构
  return { channelList }
}
export { useChannel }
